package com.example.exception;


import com.example.common.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice("com.example.controller")
public class GlobalExceptionHandler {

    @ResponseBody//返回json格式的数据

    @ExceptionHandler(Exception.class)//针对什么异常进行处理

    public Result error(Exception e){

        e.printStackTrace();

        return Result.error(e.getMessage());

    }


}


